package cn.sdc.sfw.exception;

import cn.sdc.sfw.util.MessageFormatter;

public class SfwRuntimeException extends RuntimeException {
	
	private String messageCode_;
	private Object[] args_;
	private String message_;
	private String simpleMessage_;

	public SfwRuntimeException(String messageCode) {
		this(messageCode, null, null);
	}

	public SfwRuntimeException(String messageCode, Object[] args) {
		this(messageCode, args, null);
	}

	public SfwRuntimeException(
		String messageCode,
		Object[] args,
		Throwable cause) {

		super(cause);
		messageCode_ = messageCode;
		args_ = args;
		simpleMessage_ = MessageFormatter.getSimpleMessage(messageCode_, args_);
		message_ = "[" + messageCode + "]" + simpleMessage_;
	}

	public final String getMessageCode() {
		return messageCode_;
	}

	public final Object[] getArgs() {
		return args_;
	}

	public final String getMessage() {
		return message_;
	}
	
	protected void setMessage(String message) {
		message_ = message;
	}
	
	public final String getSimpleMessage() {
		return simpleMessage_;
	}
}
